package dt.board.qna;


import com.opensymphony.xwork2.ActionSupport;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

import java.io.File;
import java.io.Reader;
import java.io.IOException;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;


public class qnaDeleteAction extends ActionSupport implements SessionAware{
	private Map session;
	public static Reader reader;
	public static SqlMapClient sqlMapper;
	
	private qnaBoardVO paramClass;
	private qnaBoardVO resultClass;
	
	private int currentPage;

	private int no;
	
	public qnaDeleteAction() throws IOException
	{
		reader = Resources.getResourceAsReader("sqlMapConfig.xml");
		sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
		reader.close();
	}

	public String execute() throws Exception {
		paramClass = new qnaBoardVO();
		resultClass = new qnaBoardVO();
		
		resultClass = (qnaBoardVO) sqlMapper.queryForObject("qna.selectOne", getNo());
		
		paramClass.setNo(getNo());
		
		sqlMapper.update("qna.deleteBoard",paramClass);
		
		return SUCCESS;
	}
	

	public qnaBoardVO getParamClass() {
		return paramClass;
	}

	public void setParamClass(qnaBoardVO paramClass) {
		this.paramClass = paramClass;
	}

	public qnaBoardVO getResultClass() {
		return resultClass;
	}

	public void setResultClass(qnaBoardVO resultClass) {
		this.resultClass = resultClass;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}


	public int getNo() {
		return no;
	}

	public void setNo(int no) {
		this.no = no;
	}

	public Map getSession() {
		return session;
	}

	public void setSession(Map session) {
		this.session = session;
	}
}
